package com.umfwechat.common;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.umfwechat.common.constant.CommonConsts;
import com.umfwechat.util.DateTimesUtil;
import com.umfwechat.util.SerialUtil;
import com.umfwechat.util.StringUtil;




public class ReqMessage implements Serializable {

	private static final long serialVersionUID = 5430574081143991769L;

	/**
	 * 请求日期
	 */
	private String reqDate = "";

	/**
	 * 请求时间
	 */
	private String reqTime = "";

	/**
	 * 请求流水
	 */
	private String rpid = "";

	public ReqMessage() {
			Date nowDate = new Date();
			this.rpid = "umfWC" + SerialUtil.getRpid(CommonConsts.RPID_SEQ, 10);
			this.reqDate = DateTimesUtil.formatDate(nowDate,DateTimesUtil.formatDay8Str);
			this.reqTime = DateTimesUtil.formatDate(nowDate,DateTimesUtil.formatTime6Str);
			
	}
	
	/**
	 * 请求
	 */
	private Map<String, Object> reqMap = new HashMap<String, Object>();

	public String toString() {
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append("rpid[").append(rpid)
		            .append("] reqDate[").append(reqDate)
		            .append("] reqTime[").append(reqTime)
		            .append("] reqMap[").append(reqMap).append("]");
		
		return stringBuffer.toString();
	}

	public void put(String key, Object value) {
		reqMap.put(key, value);
	}

	public void putAll(Map<String, Object> data) {
		reqMap.putAll(data);
	}

	public Object get(String key) {
		return reqMap.get(key);
	}
	
	public String getString(String key) {
		Object obj = reqMap.get(key);
		String param = "";
		if (obj instanceof String) {
			param = StringUtil.trim((String) obj);
		}
		
		return param;
	}

	public String getReqDate() {
		return reqDate;
	}

	public void setReqDate(String reqDate) {
		this.reqDate = reqDate;
	}

	public String getReqTime() {
		return reqTime;
	}

	public void setReqTime(String reqTime) {
		this.reqTime = reqTime;
	}

	public Map<String, Object> getReqMap() {
		return reqMap;
	}

	public void setReqMap(Map<String, Object> reqMap) {
		this.reqMap = reqMap;
	}

	public String getRpid() {
		return rpid;
	}

	public void setRpid(String rpid) {
		this.rpid = rpid;
	}
	public void put(Map<String, String> data) {
		this.reqMap.putAll(data);
	}
}
